
package model.dao;

import java.util.List;

import model.bean.District;

import com.e885.hibernate.BaseHibernateDAO;

/**
 * District Dao
 * 
 * @see model.bean.District
 * @author Eric.Kao gau168.gau@msa.hinet.net
 * @version 1.0
 * @company E885 Group
 * @copyright Copyright (c) 2001-2008
 */

public class DistrictDAO extends BaseHibernateDAO
{
	/**
	 * 
	 * @param instance
	 */
	public void attachDirty( District instance )
	{
		doAttachDirty( instance );
	}

	/**
	 * 
	 * @param persistentInstance
	 */
	public void delete( District persistentInstance )
	{
		doDelete( persistentInstance );
	}

	/**
	 * 
	 * @param id
	 * @return
	 */
	public District findById( java.lang.String id )
	{
		return ( District )doFindById( District.class, id );
	}

	/**
	 * 亂數取得一筆資料
	 * 
	 * @return
	 */
	@SuppressWarnings( "unchecked" )
	public District findRandomDistrict()
	{
		List< District > list = getNameQuery( "randomDistrict" ).list();

		if( list.size() <= 0 )
			return null;

		return list.get( 0 );
	}

	/**
	 * 
	 * @param transientInstance
	 */
	public void save( District transientInstance )
	{
		doSave( transientInstance );
	}
}